using MicroMsg.Common.Utils;
using MicroMsg.Protocol;
using Microsoft.Phone.Data.Linq;
using System;
namespace MicroMsg.Storage
{
	public class StoragePatch
	{
		public static void updateSchemaByVersion(StorageDBSchema storageDBSchema_0)
		{
			if (false | StoragePatch.updateSnsInfoTable(storageDBSchema_0))
			{
				storageDBSchema_0.version = ConstantsProtocol.CLIENT_VERSION;
				StorageDB.saveDBSchema(storageDBSchema_0);
			}
		}
		private static bool updateSnsInfoTable(StorageDBSchema storageDBSchema_0)
		{
			if (storageDBSchema_0.version > 1660944641u)
			{
				return false;
			}
			if (!StorageDB.isTableExist("SnsInfo"))
			{
				return false;
			}
			try
			{
				using (LinqDB linqDB = new LinqDB())
				{
					DatabaseSchemaUpdater databaseSchemaUpdater = Extensions.CreateDatabaseSchemaUpdater(linqDB);
					databaseSchemaUpdater.AddIndex<SnsInfo>("nObjectStyle");
					databaseSchemaUpdater.Execute();
					Log.smethod_4("StoragePatch", "add sns index nObjectStyle success");
				}
				return true;
			}
			catch (Exception)
			{
			}
			return false;
		}
	}
}
